import os
from os.path import join
import json

class ProjectManager:
	def __init__(self,project_directory="projects"):
		self.project_directory = project_directory
		#os.chdir(self.project_directory)

	def create_project(self, directory):
		os.mkdir(self.project_directory+'/'+directory)
	
	#def list_projects(self):
	#	x=os.listdir(join("/home/ratan/devel/project/dscm",self.project_directory))
	#	xmldoc = """<?xml version="1.0" encoding="UTF-8"?><projectlist>"""
	#	for i in x:
	#		xmldoc=xmldoc+"<project>"+i+"</project>"
	#	xmldoc=xmldoc+"""</projectlist>"""
	#	return xmldoc

	def list_projects(self):
		x=os.listdir(join("/home/ratan/devel/project/dscm",self.project_directory))
		l=[]
		for i in x:
			l.append(i)
		projects = {'projects':l}
		return json.dumps(projects)
